<%-- 
    Document   : index
    Created on : Jul 7, 2011, 1:23:40 AM
    Author     : Thanhluan216
--%>

<%@page import="javax.xml.stream.events.Comment"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="server.entity.Photo"%>
<%@page import="server.process.ProcessBeanLocal"%>
<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<jsp:include page="header.jsp"></jsp:include>
<div id="main">
    <div id="slidebar">
        <div id="login">
            <jsp:include page="login.jsp"></jsp:include>
        </div>
        <div id="search">
            <jsp:include page="search.jsp"></jsp:include>
        </div>
        <div id="product">
            <jsp:include page="categorypanel.jsp"></jsp:include>
        </div>
    </div>
    <div id="content">
        <%
                    Context ctx = new InitialContext();
                    ProcessBeanLocal local = (ProcessBeanLocal) ctx.lookup("ProcessLocalJNDI");
                    int photoID = 0;
                    photoID = Integer.parseInt(request.getParameter("id"));
                    local.viewPhoto(photoID);
                    Photo photo = local.searchbyID(photoID);
                    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
                    server.entity.Comment[] result = local.getListComment(photoID);



        %>
        Photo <a href='view.jsp?id=<%=request.getParameter("id")%>'><%=photo.getPhotoName()%></a> | Upload by <a href="viewuser.jsp?id=<%=photo.getRegisteredUser().getUsername()%>"><%=photo.getRegisteredUser().getUsername()%></a> | Category: <a href="category.jsp?id=<%=photo.getCategory().getCollectionID()%>"><%=photo.getCategory().getCollectionName()%></a
        <br/>
        <center>
        <table border="0">
            <tr>
                <td colspan="3"><img src="<%=photo.getServerFile()%>" height="300" width="400"/></td>
            </tr>
            <tr>
               <td><a href="comment.jsp?id=<%=request.getParameter("id")%>&action=comment">Comment</a></td>

                        <td><a href="viewallcomment.jsp?id=<%=request.getParameter("id")%>&action=viewall">View All () comment</a></td>
                        <td><a href="download?id=<%=request.getParameter("id")%>&action=download">Download this photo</a></td>
              
            </tr>
        </table>
        </center>
        <%for (int i = 0; i < result.length; i++) {


        %>
        <table>

            <tr>
                <td><%=result[i].getRegisteredUser().getUsername().toString()%></td>
                <td><%=df.format(result[i].getCommentDate())%></td>
            </tr>
            <tr>
                <td colspan="2"><%=result[i].getCommentContent()%></td>
            </tr>
        </table>

        <% }
        %>


    </div>
</div>
<div id="footer">

</div>
</div>
</body>
</html>
